<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SpringBoot 统一功能解决方案</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        /* Hero 区域样式 */
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            position: relative;
            overflow: hidden;
        }
        
        .hero-gradient::before {
            content: '';
            position: absolute;
            top: -50%;
            right: -50%;
            width: 200%;
            height: 200%;
            background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
            animation: float 20s ease-in-out infinite;
        }
        
        @keyframes float {
            0%, 100% { transform: translate(0, 0) rotate(0deg); }
            50% { transform: translate(-30px, -30px) rotate(180deg); }
        }
        
        /* 卡片悬停效果 */
        .feature-card {
            transition: all 0.3s ease;
            background: white;
            border: 1px solid #e5e7eb;
        }
        
        .feature-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
            border-color: #667eea;
        }
        
        /* 代码块样式 */
        .code-block {
            background: #1e293b;
            color: #e2e8f0;
            border-radius: 12px;
            position: relative;
            overflow: hidden;
        }
        
        .code-block::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 40px;
            background: #0f172a;
            border-bottom: 1px solid #334155;
        }
        
        .code-block pre {
            margin: 0;
            padding: 60px 24px 24px;
            overflow-x: auto;
            font-family: 'Consolas', 'Monaco', monospace;
            font-size: 14px;
            line-height: 1.6;
        }
        
        /* 首字下沉 */
        .drop-cap::first-letter {
            float: left;
            font-size: 4em;
            line-height: 0.8;
            margin: 0.1em 0.1em 0 0;
            font-weight: 700;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
        
        /* 标题装饰 */
        .section-title {
            position: relative;
            display: inline-block;
            padding-bottom: 12px;
        }
        
        .section-title::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 60px;
            height: 4px;
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        /* 数字标记 */
        .number-badge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border-radius: 50%;
            font-weight: 700;
            margin-right: 12px;
            flex-shrink: 0;
        }
        
        /* 引用样式 */
        .quote-box {
            border-left: 4px solid #667eea;
            background: #f8fafc;
            padding: 20px 24px;
            margin: 24px 0;
            border-radius: 0 8px 8px 0;
            position: relative;
        }
        
        .quote-box::before {
            content: '\f10d';
            font-family: 'Font Awesome 6 Free';
            font-weight: 900;
            position: absolute;
            top: -10px;
            left: 20px;
            font-size: 24px;
            color: #667eea;
            background: white;
            padding: 0 8px;
        }
        
        /* 按钮样式 */
        .gradient-btn {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 12px 32px;
            border-radius: 8px;
            font-weight: 600;
            transition: all 0.3s ease;
            display: inline-block;
            text-decoration: none;
        }
        
        .gradient-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 20px -5px rgba(102, 126, 234, 0.4);
        }
        
        /* Mermaid 图表容器 */
        .mermaid-container {
            background: white;
            border-radius: 12px;
            padding: 24px;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
            margin: 32px 0;
        }
    </style>
</head>
<body>
    <!-- Hero 区域 -->
    <section class="hero-gradient text-white py-20 relative">
        <div class="container mx-auto px-6 relative z-10">
            <div class="max-w-4xl mx-auto text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6 leading-tight">
                    使用 SpringBoot 解决项目统一功能
                </h1>
                <p class="text-xl md:text-2xl mb-8 opacity-90">
                    高效、优雅、易维护的企业级解决方案
                </p>
                <div class="flex flex-wrap justify-center gap-4 text-lg">
                    <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full">
                        <i class="fas fa-layer-group mr-2"></i>拦截器
                    </span>
                    <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full">
                        <i class="fas fa-cut mr-2"></i>AOP切面
                    </span>
                    <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full">
                        <i class="fas fa-shield-alt mr-2"></i>全局异常处理
                    </span>
                </div>
            </div>
        </div>
    </section>

    <!-- 主要内容区域 -->
    <main class="container mx-auto px-6 py-12 max-w-6xl">
        <!-- 引言部分 -->
        <section class="bg-white rounded-2xl shadow-lg p-8 md:p-12 mb-12">
            <p class="text-lg leading-relaxed text-gray-700 drop-cap">
                在企业级 Java 项目开发中，我们常常需要处理<strong class="text-purple-600">日志记录、异常处理、权限校验、请求参数校验等通用功能</strong>。如果每个模块都单独实现这些功能，不仅代码冗余，还会增加维护成本。
            </p>
            <p class="text-lg leading-relaxed text-gray-700 mt-4">
                Spring 框架提供了一系列<strong class="text-purple-600">非侵入式</strong>的解决方案，如<strong class="text-purple-600">拦截器（Interceptor）、AOP（Aspect-Oriented Programming）、全局异常处理</strong>等，让我们能够<strong class="text-purple-600">优雅地</strong>解决这些统一功能问题。
            </p>
        </section>

        <!-- 为什么需要统一功能 -->
        <section class="mb-12">
            <h2 class="text-3xl font-bold mb-8 section-title">为什么需要统一功能？</h2>
            <div class="grid md:grid-cols-2 gap-6">
                <div class="feature-card rounded-xl p-6">
                    <div class="flex items-start">
                        <span class="number-badge">1</span>
                        <div>
                            <h3 class="text-xl font-semibold mb-2">日志记录</h3>
                            <p class="text-gray-600">每个请求都需要打印日志，如果在 Controller 里手写 <code class="bg-gray-100 px-2 py-1 rounded text-sm">System.out.println()</code>，代码会非常冗余。</p>
                        </div>
                    </div>
                </div>
                <div class="feature-card rounded-xl p-6">
                    <div class="flex items-start">
                        <span class="number-badge">2</span>
                        <div>
                            <h3 class="text-xl font-semibold mb-2">异常处理</h3>
                            <p class="text-gray-600">如果每个方法都 <code class="bg-gray-100 px-2 py-1 rounded text-sm">try-catch</code>，代码不仅繁琐，还降低了可读性。</p>
                        </div>
                    </div>
                </div>
                <div class="feature-card rounded-xl p-6">
                    <div class="flex items-start">
                        <span class="number-badge">3</span>
                        <div>
                            <h3 class="text-xl font-semibold mb-2">权限校验</h3>
                            <p class="text-gray-600">有些 API 需要权限控制，如果每个接口都手动检查权限，维护起来非常麻烦。</p>
                        </div>
                    </div>
                </div>
                <div class="feature-card rounded-xl p-6">
                    <div class="flex items-start">
                        <span class="number-badge">4</span>
                        <div>
                            <h3 class="text-xl font-semibold mb-2">请求参数校验</h3>
                            <p class="text-gray-600">如果每个 Controller 里都手写 <code class="bg-gray-100 px-2 py-1 rounded text-sm">if</code> 语句检查参数合法性，代码可读性会很差。</p>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="quote-box mt-8">
                <p class="text-gray-700">这些功能都是<strong>通用功能</strong>，不应该和业务逻辑代码混在一起。因此，我们需要<strong>Spring 提供的机制</strong>，来解决这些问题。</p>
            </div>
        </section>

        <!-- 解决方案概览 -->
        <section class="mb-12">
            <h2 class="text-3xl font-bold mb-8 section-title">解决统一功能的 SpringBoot 方案</h2>
            
            <!-- 可视化图表 -->
            <div class="mermaid-container">
                <div class="mermaid">
                    graph TD
                        A[统一功能需求] --> B[Spring 解决方案]
                        B --> C[拦截器 Interceptor]
                        B --> D[AOP 切面编程]
                        B --> E[全局异常处理]
                        
                        C --> F[全局请求拦截]
                        C --> G[日志记录]
                        C --> H[权限校验]
                        
                        D --> I[方法级别拦截]
                        D --> J[事务管理]
                        D --> K[性能监控]
                        
                        E --> L[统一异常管理]
                        E --> M[避免 try-catch]
                        E --> N[统一返回格式]
                        
                        style A fill:#f9f,stroke:#333,stroke-width:2px
                        style B fill:#bbf,stroke:#333,stroke-width:2px
                        style C fill:#9f9,stroke:#333,stroke-width:2px
                        style D fill:#9f9,stroke:#333,stroke-width:2px
                        style E fill:#9f9,stroke:#333,stroke-width:2px
                </div>
            </div>
            
            <div class="grid md:grid-cols-3 gap-6 mt-8">
                <div class="bg-gradient-to-br from-blue-50 to-indigo-100 rounded-xl p-6">
                    <div class="text-indigo-600 text-3xl mb-4">
                        <i class="fas fa-filter"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-2">拦截器（Interceptor）</h3>
                    <p class="text-gray-700">适用于<strong>全局请求拦截</strong>，比如日志记录、权限校验等。</p>
                </div>
                <div class="bg-gradient-to-br from-purple-50 to-pink-100 rounded-xl p-6">
                    <div class="text-purple-600 text-3xl mb-4">
                        <i class="fas fa-code-branch"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-2">AOP（切面编程